unic-langid
unic-langid
is an API for managing Unicode Language Identifiers.
The crate provides a way to create a struct from a string, manipulate its fields, canonicalize it, and serialize into a string.
Usage
use LanguageIdentifier;
let loc: LanguageIdentifier = "en-US".parse.expect;
assert_eq!;
assert_eq!;
assert_eq!;
loc.set_script;
assert_eq!;
use LanguageIdentifier;
let langid = from_parts.expect;
assert_eq!
Macros
unic-langid
can be also compiled with features = ["macros"]
which enables langid!
macro:
use langid;
// The `const` assignment will currently work only
// if the langid doesn't contain any variants.
const EN_US: LanguageIdentifier = langid!;
The macro allows for compile-time parsing and validation of literal language identifiers.
Status
The crate is mostly complete on the well-formed
level. The next batch of work will go into
API maturity.
Get Involved
unic-langid
is open-source, licensed under the Apache License, Version 2.0. We
encourage everyone to take a look at our code and we'll listen to your
feedback.